package com.example.tingshu.service;

import com.example.tingshu.dao.AlbumDao;
import com.example.tingshu.model.Album;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AlbumService {
    private AlbumDao albumDao;

    @Autowired
    public AlbumService(AlbumDao albumDao) {
        this.albumDao = albumDao;
    }

    public List<Album> list(String keyword){
        if (keyword != null){
            return albumDao.selectListByKeyword(keyword);
        }else {
            return albumDao.selectList();
        }
    }

    public Object myList(Integer uid) {
        return albumDao.selectListByUid(uid);
    }

    public void save(Integer uid, String name, String cover) {
        albumDao.insert(uid,name,cover);
    }
}
